from django import forms
from .models import CustomUser
from django.forms import widgets


class LoginForm(forms.Form):
    username = forms.CharField(label="用户名", widget=widgets.TextInput(attrs={
        "id": "username",
        "class": "form-control",
    }), )
    password = forms.CharField(label="密码", widget=widgets.PasswordInput(attrs={
        "id": "password",
        "class": "form-control",
    }))


class RegisterForm(forms.ModelForm):
    password2 = forms.CharField(label="密码", widget=widgets.PasswordInput(attrs={
        "id": "password2",
        "class": "form-control",
        "placeholder": "再次输入密码",
    }))

    class Meta:
        model = CustomUser
        fields = ["username", "password", ]
        widgets = {
            "username": forms.TextInput(attrs={
                "id": "username",
                "class": "form-control",
                "placeholder": "输入用户名",
            }),
            "password": forms.PasswordInput(attrs={
                "id": "password",
                "class": "form-control",
                "placeholder": "输入密码",
            }),
        }


class CenterForm(forms.ModelForm):
    class Meta:
        model = CustomUser
        fields = ["head", "username", "email", "telephone", "first_name", "last_name", ]
        widgets = {
            "username": forms.TextInput(attrs={
                "id": "username",
                "class": "form-control",
                "placeholder": "输入用户名",
            }),
            "email": forms.EmailInput(attrs={
                "id": "email",
                "class": "form-control",
                "placeholder": "输入邮箱",
            }),
            "telephone": forms.TextInput(attrs={
                "id": "telephone",
                "class": "form-control",
                "placeholder": "输入手机号",
            }),
            "first_name": forms.TextInput(attrs={
                "id": "first_name",
                "class": "form-control",
                "placeholder": "输入姓氏",
            }),
            "last_name": forms.TextInput(attrs={
                "id": "last_name",
                "class": "form-control",
                "placeholder": "输入姓名",
            }),
        }


class UpdatePwdForm(forms.Form):
    password1 = forms.CharField(label="原始密码", widget=widgets.PasswordInput(attrs={
        "id": "password1",
        "class": "form-control",
        "placeholder": "输入原始密码",
    }))
    password2 = forms.CharField(label="新密码", widget=widgets.PasswordInput(attrs={
        "id": "password2",
        "class": "form-control",
        "placeholder": "输入新密码",
    }))
    password3 = forms.CharField(label="确认新密码", widget=widgets.PasswordInput(attrs={
        "id": "password3",
        "class": "form-control",
        "placeholder": "确认新密码",
    }))

